<?php

namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use \App\Models\Divination;
use \App\Models\Category;
use Encore\Admin\Facades\Admin;
use App\Services\MakeProductThumbnail\MakeProductThumbnail;
use App\Admin\Actions\DivinationAction\MakeDeepThink;

class ZzxjDivinationController extends AdminController
{
    protected $title = '字字玄机本挂配置';
    
    protected function grid()
    {
        $grid = new Grid(new Divination());

	    $grid->disableExport();
	
	    $grid->column('id', 'ID');
	    $grid->column('title', '卜卦标题');
	    $grid->column('upper_num', '上挂数');
	    $grid->column('lower_num', '下挂数');
	  
	   
	    $grid->column('created_at', '创建时间')->display(function () {
		    return $this->created_at->toDatetimeString();
	    });
	
	    $grid->disableRowSelector();
	    $this->gridActions($grid);
        return $grid;
    }

     protected function gridActions(Grid $grid)
    {
	    $grid->actions(function (Grid\Displayers\Actions $actions) {
	    	$actions->disableDelete();

	   //  	if (in_array(Admin::user()->id, [1,2])) {
		  //   	$actions->add(new MakeDeepThink());

 			// }
		    
	    });
    }
	
	 protected function detail($id)
    {
        $show = new Show(Divination::findOrFail($id));
        return $show;
    }
	
    protected function form()
    {
        $form = new Form(new Divination());

	    $form->text('title', '卜卦标题')->rules('required');
	    $form->number('upper_num', '上挂数')->rules('required');
	    $form->number('lower_num', '下挂数')->rules('required');
	   
	    $form->textarea('shiyi', '字字玄机本挂释义')->rules('required');
	    
	    //$this->formSaved($form);
        return $form;
    }

   
}
